<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>地图坐标拾取</title>

    <link rel="stylesheet" href="./css/ol.css" />
    <script src="./js/ol.js"></script>
</head>
<body>
<div id="map"></div>
<script>
    let map = new ol.Map({
        target: "map", // 关联到对应的div容器
        layers: [
            new ol.layer.Tile({
                // 瓦片图层
                source: new ol.source.OSM(), // OpenStreetMap数据源
            }),
        ],
        view: new ol.View({
            // 地图视图
            projection: "EPSG:3857",
            center: [0, 0],
            zoom: 0,
        }),
        controls: ol.control.defaults().extend([
            new ol.control.MousePosition(), // 实例化坐标拾取控件，并加入地图
        ]),
    });
</script>
</body>
</html>
